home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-08-16 | 5.1 KB | 206 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: DrwPrmse.cpp
- // Release Version: $ ODF 1 $
- //
- // Author: Henri Lamiraux
- //
- // Copyright: (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "ODFDraw.hpp"
-
- #ifndef DRWPRMSE_H
- #include "DrwPrmse.h"
- #endif
-
- #ifndef DRAWCONT_H
- #include "DrawCont.h"
- #endif
-
- #ifndef BINDING_K
- #include "Binding.k"
- #endif
-
- #ifndef DRAWPRXY_H
- #include "DrawPrxy.h"
- #endif
-
- #ifndef DRAWPART_H
- #include "DrawPart.h"
- #endif
-
- #ifndef DRAWSEL_H
- #include "DrawSel.h"
- #endif
-
- #ifndef BASESHP_H
- #include "BaseShp.h"
- #endif
-
- #ifndef BOUNDSHP_H
- #include "BoundShp.h"
- #endif
-
- #ifndef LINESHP_H
- #include "LineShp.h"
- #endif
-
- #ifndef OVALSHP_H
- #include "OvalShp.h"
- #endif
-
- #ifndef RECTSHP_H
- #include "RectShp.h"
- #endif
-
- #ifndef RRECTSHP_H
- #include "RRectShp.h"
- #endif
-
- #ifndef TEXTSHP_H
- #include "TextShp.h"
- #endif
-
- #ifndef UTILS_H
- #include "Utils.h"
- #endif
-
- // ----- OS Layer -----
-
- #ifndef FWSUSINK_H
- #include "FWSUSink.h"
- #endif
-
- #ifndef FWORDCOL_H
- #include "FWOrdCol.h"
- #endif
-
- #ifndef FWPICTUR_H
- #include "FWPictur.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWSTREAM_H
- #include "FWStream.h"
- #endif
-
- #ifndef FWPRISTR_H
- #include "FWPriStr.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- #ifndef FWMEMHLP_H
- #include "FWMemHlp.h"
- #endif
-
- // ----- OpenDoc Includes -----
-
- #ifndef SOM_Module_OpenDoc_StdProps_defined
- #include <StdProps.xh>
- #endif
-
- #if defined(__MWERKS__) && GENERATING68K
- // A hack to work around a bug
- #pragma import list somGetGlobalEnvironment
- #endif
-
- //========================================================================================
- // RunTime Info
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- #pragma segment odfdraw
- #endif
-
- //========================================================================================
- // class CDrawSelectionPromise
- //========================================================================================
-
- //----------------------------------------------------------------------------------------
- // CDrawSelectionPromise::CDrawSelectionPromise
- //----------------------------------------------------------------------------------------
-
- CDrawSelectionPromise::CDrawSelectionPromise(Environment*ev,
- FW_EStorageKinds storageKind,
- FW_CCloneInfo* cloneInfo,
- CDrawPromiseContent* promisedContent) :
- FW_CPromise(ev, storageKind, cloneInfo),
- fPromisedContent(promisedContent)
- {
- CDrawContentShapeIterator ite(fPromisedContent);
- for (CBaseShape *shape = ite.First(); ite.IsNotComplete(); shape = ite.Next())
- shape->Promised(storageKind, TRUE);
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawSelectionPromise::~CDrawSelectionPromise
- //----------------------------------------------------------------------------------------
-
- CDrawSelectionPromise::~CDrawSelectionPromise()
- {
- Environment* ev = somGetGlobalEnvironment();
- CDrawContentShapeIterator ite(fPromisedContent);
- for (CBaseShape *shape = ite.First(); ite.IsNotComplete(); shape = ite.Next())
- shape->Promised(GetStorageKind(ev), FALSE);
-
- delete fPromisedContent;
- }
-
- //----------------------------------------------------------------------------------------
- // CDrawSelectionPromise::FulfillPromise
- //----------------------------------------------------------------------------------------
-
- void CDrawSelectionPromise::FulfillPromise(Environment *ev,
- ODStorageUnitView *promiseSUView,
- ODPropertyName propertyName,
- ODValueType valueType,
- FW_CCloneInfo* cloneInfo)
- {
- FW_ASSERT(FW_PrimitiveStringEqual(propertyName, kODPropContents));
- if (FW_PrimitiveStringEqual(valueType, kODFDrawKind))
- {
- fPromisedContent->Externalize(ev, promiseSUView->GetStorageUnit(ev), GetStorageKind(ev), cloneInfo);
- }
- else if (FW_PrimitiveStringEqual(valueType, FW_CPart::gMacPICTDataType))
- {
- FW_CPicture picture;
-
- {
- FW_CRect selectionRect = fPromisedContent->GetSelectedRect();
- FW_CPictureContext pc(ev, picture, selectionRect.Width(), selectionRect.Height());
-
- // ----- Clone the contents of the selection -----
- CDrawContentShapeIterator ite(fPromisedContent);
- for (CBaseShape *shape = ite.First(); ite.IsNotComplete(); shape = ite.Next())
- {
- if (shape->GetShapeType() != kProxyShape)
- {
- shape->OffsetShape(ev, -selectionRect.left, -selectionRect.top);
- shape->RenderShape(ev, NULL, pc);
- shape->OffsetShape(ev, selectionRect.left, selectionRect.top);
- }
- }
- }
-
- FW_PlatformPict platformPict = picture.GetPlatformPict();
-
- unsigned long pictSize = FW_CMemoryManager::GetSystemHandleSize((FW_PlatformHandle)platformPict);
-
- FW_CAcquireLockedSystemHandle lockedHandle((FW_PlatformHandle)platformPict);
-
- FW_PStorageUnitSink suSink(ev, promiseSUView);
- FW_CWritableStream stream(suSink);
- stream.Write(lockedHandle.GetPointer(), pictSize);
- }
- #ifdef FW_DEBUG
- else
- FW_DEBUG_MESSAGE("CDrawDesignator::Externalize - Unknown type");
- #endif
- }
-